package com.xtkj.superclub_information.service.impl;

import com.xtkj.superclub_entity.entity.travel.Travel;
import com.xtkj.superclub_entity.entity.travel.TravelComment;
import com.xtkj.superclub_information.dao.TravelCommentDao;
import com.xtkj.superclub_information.dao.TravelDao;
import com.xtkj.superclub_information.service.ITravelCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author lizheqi
 * @create 2020-01-04-9:44
 */
@Service
public class TravelCommentServiceImpl implements ITravelCommentService {
    @Autowired
    private TravelCommentDao travelCommentDao;
    @Autowired
    private TravelDao travelDao;

    /**
     * 根据游记评论编号获取游记评论
     * @param travelCommentId
     * @return
     */
    @Override
    public TravelComment getCommentById(String travelCommentId) {
        return travelCommentDao.selectById(travelCommentId);
    }

    /**
     * 游记评论
     * @param travelComment
     */
    @Override
    public void comment(TravelComment travelComment) {
        travelComment.setUpdatedtm(new Date()).setCreatedtm(new Date());
        travelCommentDao.insert(travelComment);
        //游记评论之后更新游记
        Travel travel = travelDao.selectById(travelComment.getTravelId());
        travel.setUpdatedtm(new Date());
        travelDao.updateById(travel);
    }
}
